package com.zkca.xf.ui.activity.personprotect;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zkca.xf.ConstantsXF;
import com.zkca.xf.R;
import com.zkca.xf.base.BaseTitleActivity;
import com.zkca.xf.model.javabean.FaultJobLBean;
import com.zkca.xf.utils.LogUtil;
import com.zkca.xf.utils.TimeUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class FaultCompleteActivity extends BaseTitleActivity {

    @BindView(R.id.faultnum)
    TextView faultnum;
    @BindView(R.id.devid)
    TextView devid;
    @BindView(R.id.devname)
    TextView devname;
    @BindView(R.id.installposition)
    TextView installposition;
    @BindView(R.id.xunjianuser)
    TextView xunjianuser;
    @BindView(R.id.xunjiantime)
    TextView xunjiantime;
    @BindView(R.id.commun)
    TextView commun;
    @BindView(R.id.imagadd)
    ImageView imagadd;
    @BindView(R.id.imaglinear)
    LinearLayout imaglinear;
    @BindView(R.id.imagandtext)
    LinearLayout imagandtext;
    @BindView(R.id.devstatus)
    TextView devstatus;
    @BindView(R.id.hanldmsg)
    TextView hanldmsg;
    FaultJobLBean.DataBean dataBean;
    String devImage4;
    String name3;
    int faultId;
    @BindView(R.id.wanchengtime)
    TextView wanchengtime;
    @BindView(R.id.jiejueren)
    TextView jiejueren;

    private int type1 = -1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fault_complete);
        ButterKnife.bind(this);
        setTitleText("故障处理结果");
        setleftTextVisibility(true);
        setleftImgVisibility(true);

        initViewData();
    }

    private void initViewData() {
        Intent intent = getIntent();
        dataBean = (FaultJobLBean.DataBean) intent.getSerializableExtra("jobbean");
        devImage4 = (String) dataBean.getDevImage4();
//                LogUtil.e(dataBean.getName3()+"图片：",devImage4+"");
        name3 = dataBean.getName3();//故障编号
        int handleResult = dataBean.getHandleResult();//执行状态  1 为执行 2 已执行
        String handleUname = dataBean.getHandleUname();//指派用户
        String devName = dataBean.getDevName();//设备名称
        String installPosition = dataBean.getInstallPosition();//设备地点
        String name1 = dataBean.getName1();//问题描述
        faultId = dataBean.getFaultId();//故障ID
        long createTime = dataBean.getCreateTime();
        String formatDate2 = TimeUtils.getFormatDate2(createTime);
        long handleTime = dataBean.getHandleTime();
        String formatDate3 = TimeUtils.getFormatDate2(handleTime);

        jiejueren.setText(dataBean.getHandleUname());
        faultnum.setText(name3);
        devid.setText(dataBean.getDevId());
        devname.setText(devName);
        installposition.setText(installPosition);
        xunjianuser.setText(dataBean.getUserName());
        xunjiantime.setText(formatDate2);
        boolean contains = name1.contains("<br/>");
        if (contains){
            name1= name1.replace("<br/>","注：");
        }
        commun.setText(name1);

        int type1 = dataBean.getType1();
        if (type1 == 0) {
            devstatus.setText("已解决");
        } else {
            devstatus.setText("未解决");
        }

        wanchengtime.setText(formatDate3);
        hanldmsg.setText(dataBean.getHandleDesc() + "");
        LogUtil.e("Image4==", ConstantsXF.URL_SERVER_CE + devImage4);
        Glide.with(this).load(ConstantsXF.URL_SERVER_CE + devImage4).asBitmap().placeholder(R.mipmap.zwf).error(R.mipmap.zwf).into(imagadd);
    }
}
